package com.bkgy.modular.oneTouchQuality.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bkgy.modular.oneTouchQuality.entity.CurveAnalysis;
import com.bkgy.modular.oneTouchQuality.mapper.CurveAnalysisMapper;
import com.bkgy.modular.oneTouchQuality.service.CurveAnalysisService;
import com.bkgy.sys.common.entity.ResultData;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhuHongKai
 * @version 1.0
 * @ClassName CurveAnalysisServiceImpl
 * @date 2022/12/22 16:55
 */
@Service
public class CurveAnalysisServiceImpl extends ServiceImpl<CurveAnalysisMapper, CurveAnalysis> implements CurveAnalysisService {

    @Resource
    private CurveAnalysisMapper curveAnalysisMapper;

    @Override
    public ResultData curveAnalysis(JSONObject jsonObject) {
        String coldCoilId = jsonObject.getString("coldCoilId");
        String fieldName = jsonObject.getString("fieldName");
        List<Double> doubleList = new ArrayList<>();
        Double number = curveAnalysisMapper.findByNumber(coldCoilId,fieldName);
        doubleList.add(number);
        List<Double> list = curveAnalysisMapper.findByData(coldCoilId, fieldName);
        for (Double item : list) {
            doubleList.add(item);
        }
        return ResultData.ResultDataFaultSelf("操作成功",doubleList);
    }

    @Override
    public ResultData curveAnalysis2(JSONObject jsonObject) {

        String coldCoilId = jsonObject.getString("coldCoilId");
        String fieldName = jsonObject.getString("fieldName");
        List<Double> doubleList = new ArrayList<>();
        Double number = curveAnalysisMapper.findByNumber2(coldCoilId,fieldName);
        doubleList.add(number);
        List<Double> list = curveAnalysisMapper.findByData2(coldCoilId, fieldName);
        for (Double item : list) {
            doubleList.add(item);
        }
        return ResultData.ResultDataFaultSelf("操作成功",doubleList);
    }
}
